package chapter17;

/**
 * @Auther: Tx
 * @Date: 2022/7/13 11:06
 */

//线程的状态，细分为其中，Runnable状态可分为两个，ready和Running
public class TheadState_ {
    public static void main(String[] args) throws InterruptedException {
        T_state t_state = new T_state();
        System.out.println("线程状态"+t_state.getState());
        t_state.start();

        while(t_state.getState()!= Thread.State.TERMINATED)
        {
            System.out.println("线程状态"+t_state.getState());
            Thread.sleep(100);
        }
        System.out.println("线程状态"+t_state.getState());
    }

}
class T_state extends Thread{
    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("子线程运行" + i);
            }
          break;
        }
    }
}
